"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.幽灵Handler = void 0;
const Config_1 = require("../../Config");
const Big_1 = require("../Big");
const Utils_1 = __importDefault(require("../Utils"));
class 幽灵Handler {
    constructor(gameMgr, handlerMgr) {
        this.gameMgr = gameMgr;
        this.handlerMgr = handlerMgr;
    }
    gc() {
        this.gameMgr = null;
        this.handlerMgr = null;
    }
    幽灵_move(data, player) {
        this.handlerMgr.spendAction(player, Config_1.Config.COST_幽灵_MOVE);
        let startPoint = this.gameMgr.map_point.get(data.start);
        let endPoint = this.gameMgr.map_point.get(data.end);
        let big_start = startPoint.big;
        let big_end = endPoint.big;
        if (big_end != null) {
            this.handlerMgr.fail(player, "移动失败");
            big_end.deleteState(Big_1.BigState.HIDE);
            big_start.die();
            return;
        }
        startPoint.big = null;
        endPoint.big = big_start;
        big_start.point = endPoint;
        this.gameMgr.sendBroadcast(Utils_1.default.getObj("big_move", { "start": data.start, "end": data.end }));
        big_start.enterCooling();
    }
    幽灵_impact(data, player) {
        this.handlerMgr.spendAction(player, Config_1.Config.COST_幽灵_IMPACT);
        let startPoint = this.gameMgr.map_point.get(data.start);
        let endPoint = this.gameMgr.map_point.get(data.end);
        let big_start = startPoint.big;
        let big_end = endPoint.big;
        if (big_end != null) {
            big_end.deleteState(Big_1.BigState.HIDE);
            big_end.addState(Big_1.BigState.FEAR);
            big_start.die();
            return;
        }
        startPoint.big = null;
        endPoint.big = big_start;
        big_start.point = endPoint;
        this.gameMgr.sendBroadcast(Utils_1.default.getObj("big_move", { "start": data.start, "end": data.end }));
        big_start.enterCooling();
    }
}
exports.幽灵Handler = 幽灵Handler;
